<?php 
include_once(''.P.'/public/header.html');
?>

<script type="text/javascript" src="res/bootstrapplugin/jquery-bootstable.js"></script>
<script type="text/javascript" src="res/menu/jquery-rockmenu.js"></script>
<link rel="stylesheet" type="text/css" href="res/menu/jquery-rockmenu.css">


<script>

function initbody(){
	
	table = $('#viewshow').bootstable({
		url:'index.php?m=agent&d=manage&a=data&cnum='+cnum+'',method:'get',celleditor:true,table:'0',
		fanye:false,cellurl:'index.php?a=savecell',
		columns:[{
			text:'图标',dataIndex:'picurl',renderer:function(v){
				if(v)v='<img src="'+v+'" width="30">';
				return v;
			}
		},{
			text:'编号',dataIndex:'num'
		},{
			text:'名称',dataIndex:'name',editor:true
		},{
			text:'分类',dataIndex:'types',editor:true
		},{
			text:'agentkey',dataIndex:'agentkey',editor:true
		},{
			text:'应用地址',dataIndex:'url',renderer:function(v,d){
				if(!v && !d.murl)return '<font color=gray>未设置</font>';
				return '已设置';
			}
		},{
			text:'状态',dataIndex:'status',store:[['0','停用'],['1','启用'],['2','仅PC端'],['3','仅手机端']],sortable:true,editor:true,type:'select',renderer:function(v){
				if(v=='0')return '停用';
				if(v=='1')return '启用';
				if(v=='2')return '仅PC端';
				if(v=='3')return '仅手机端';
			}
		},{
			text:'ID',dataIndex:'id'
		},{
			text:'负责人',dataIndex:'fzname'
		},{
			text:'适用对象',dataIndex:'recename'
		},{
			text:'排序号',dataIndex:'sort',sortable:true,type:'number',editor:true,textmsg:'越小越靠前'
		},{
			text:'直接打开',dataIndex:'iszy',sortable:true,type:'checkbox',editor:true,textmsg:'应用中心直接打开主页'
		},{
			text:'',dataIndex:'opts',renderer:function(s,d){
				return '<a class="zhu" href="?m=agent&d=manage&cnum='+cnum+'&a=form&id='+d.id+'">编辑</a>&nbsp;<a class="zhu" href="javascript:;" onclick="sendxiaoxi('+d.id+')">发消息</a>&nbsp;<a class="zhu" href="javascript:;" onclick="deleterecord('+d.id+',0,false)">删</a>';
			}
		}]
		
		
	});
}
function getcode(id){
	var str = '&lt;script src="'+NOWURL+'?m=front&key='+id+'"&gt;&lt;/script&gt;';
	js.alert('在你的页面引入如下代码：<br>'+str);
}
function sendxiaoxi(id){
	js.prompt('输入消息内容',function(jg,txt){
		if(jg=='yes' && txt){
			js.loading('发送中...');
			js.ajax({
				url:'?d=manage&m=agent&cnum='+cnum+'&a=sendmsg',
				data:{cont:txt,agentid:id},
				type:'post',
				dataType:'json',
				success:function(ret){
					if(ret.success){
						js.msgok('发送成功');
					}else{
						js.msgerror(ret.msg);
					}
				}
			});
		}
	},'给“<?=$userainfo['name']?>”发消息');
}
</script>
</head>

<body style="background:#f1f1f1">

<?php 
include_once(''.P.'/public/top_manage.html');
?>

<div align="center">

<div style="width:<?=$maxwidth?>;margin:20px 0px" align="left">
	<div style="color:#cccccc">
		<a href="?d=manage&cnum=<?=$cnum?>" class="zhu"><?=lang('manage.home')?></a> &gt;
		<a href="" class="zhu"><?=lang('admin.agenttitle')?></a>
	</div>
	<div class="mainbody">
		<div style="padding:10px">
			<div style="padding:5px 0px"><a class="webbtn"  href="?m=agent&cnum=<?=$cnum?>&d=manage&a=form&id=0">新增</a></div>
			<div class="blank10"></div>
			<div id="viewshow" style="overflow:auto"></div>
		</div>
		<div class="blank10"></div>
	</div>
</div>



<?php 
include_once(''.P.'/public/footer.html');
?>
</div>

</body>
</html>